<div class="form">
<?php

$form=$this->beginWidget('CActiveForm',array(
    'id'=>'jobs-form',
    'enableAjaxValidation'=>true,
    'action'=>'index.php?r=jobs/'.$request,
));
?>
        
    <?php echo $form->hiddenField($model,'custno');?>
    <?php echo $form->hiddenField($model,'locno');?>
    <div class="row short">
        <?php echo $form->labelEx($model,'jobid');?>
        <?php echo $form->textField($model,'jobid');?>
        <?php echo $form->error($model,'jobid');?>
    </div>
    
    <div class="row short">
        <?php echo $form->labelEx($model,'billloc');?>
        <?php echo $form->dropDownList($model,'billloc',CHtml::listData(Invoice::model()->getBillToList($model->custno), 'id', 'locname'));?>
        <?php echo $form->error($model,'billloc');?>
    </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'department');?>
            <?php echo $form->dropDownList($model,'department',  SalesDepartments::getListData());?>
            <?php echo $form->error($model,'department');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'supervisor');?>
            <?php echo $form->dropDownList($model,'supervisor',Employees::model()->getEmployeeList());?>
            <?php echo $form->error($model,'supervisor');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'jobsalesperson');?>
            <?php echo $form->dropDownList($model,'jobsalesperson',  Employees::model()->getEmployeeList());?>
            <?php echo $form->error($model,'jobsalesperson');?>
        </div>
        
        <div class="row short">
            <?php echo $form->labelEx($model,'customerpo');?>
            <?php echo $form->textField($model,'customerpo');?>
            <?php echo $form->error($model,'customerpo');?>
        </div>
        
    <div class="row short">
        <?php echo $form->labelEx($model,'billingstatus');?>
        <?php echo $form->dropDownList($model,'billingstatus',  JobsBillingStatus::getListData());?>
        <?php echo $form->error($model,'billingstatus');?>
    </div>
    <div class="row short">
        <?php echo $form->labelEx($model,'post');?>
        <?php echo $form->textField($model,'post');?>
        <?php echo $form->error($model,'post');?>
    </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'start');?>
            <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                    'model'=>$model,
                    'attribute'=>'start',
                    'value'=>CTimestamp::formatDate('m-d-Y',$model->start),
                    'options' => array('start'=>'m-d-yy'),
                )); ?>
            <?php echo $form->error($model,'start');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'projend');?>
            <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                    'model'=>$model,
                    'attribute'=>'projend',
                    'value'=>CTimestamp::formatDate('m-d-Y',$model->projend),
                    'options' => array('projend'=>'m-d-yy'),
                )); ?>
            <?php echo $form->error($model,'projend');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'actualend');?>
            <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                    'model'=>$model,
                    'attribute'=>'actualend',
                    'value'=>CTimestamp::formatDate('m-d-Y',$model->actualend),
                    'options' => array('actualend'=>'m-d-yy'),
                )); ?>
            <?php echo $form->error($model,'actualend');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'closedate');?>
            <?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(
                    'model'=>$model,
                    'attribute'=>'closedate',
                    'value'=>CTimestamp::formatDate('Y-m-d',$model->closedate),
                    'options' => array('closedate'=>'yy-m-d'),
                )); ?>
            <?php echo $form->error($model,'closedata');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'installcrew');?>
            <?php echo $form->textField($model,'installcrew');?>
            <?php echo $form->error($model,'installcrew');?>
        </div>
        <div class="row short">
            <?php echo $form->labelEx($model,'jobstatus');?>
            <?php echo $form->dropDownList($model, 'jobstatus', JobsStatus::getListData());?>
            <?php echo $form->error($model,'jobstatus');?>
        </div>
    
    <div class="row">
        <?php echo $form->labelEx($model,'description');?>
        <script>
            function insertTime(){
                var notes=$('#Jobs_description');
                if((notes.val().trim())==''){
                    notes.val( notes.val()+getDate()+' ');
                }else{
                    notes.val( notes.val()+'\n'+getDate()+' ');
                }
                notes.focusEnd();
            }
        </script>
        <a href="javasript:void(0)" onclick="insertTime();">Insert Date/Time</a>
        <br/>
        <?php echo $form->textArea($model,'description',array('style'=>'width:250px;'));?>
        <?php echo $form->error($model,'description');?>
    </div>
    
    <div class="row_buttons">
        <?php echo CHtml::ajaxSubmitButton('Save', 'index.php?r=jobs/create', array(
            'success'=>'js:function(data){
                    if(data=="true"){
                        $("#add-item").dialog("close");
                    }
                }'
        ));?>
    </div>
<?php $this->endWidget()?>
</div>